import org.junit.Test;

/**
 * @author 19401
 * @date 2022/7/13 13:57
 **/
public class SumMain {
    @Test
    public void test02() {
        for (int i = 1; i <= 100; i++) {
            int i1 = 100 - i;
            System.out.println(String.format("%s/%s=%s\t%s", i1, i, (i1 / i), i1 % i));
        }
        int m = 89;
        int n = 11;
        int min = m < n ? m : n;          //找出最小数
        for (int i = min; i > 0; i--) {     //从大到小除
            if (m % i == 0) {
                min = i;
                break;         //第一个就是最大公约数，break跳出
            }
        }
        int max = m * n / min;       //最小公倍数
        System.out.println("最大公约数：" + min);
        System.out.println("最小公倍数：" + max);
    }
    @Test
    public void test01() {
        Integer a = 30;
        Integer b = 70;
//        a = 20;
//        b = 80;
//        a = 89;
//        b = 11;
        a = 89; b = 11;
        a = 80; b = 20;
//        a = 66; b = 34;

        Integer min = Math.min(a, b);
        Integer max = Math.max(a, b);
        Integer minCount = 0;
        Integer maxCount = 0;
        if (base(min, max)) {
            return;
        }
        if (min > 25) {
            int i = max / 3;
            boolean isBreak = true;
            while (isBreak) {
                if (max % i != 0) {
                    isBreak = false;
                } else {
                    i--;
                }
            }
            int minRemainder = min % i;
            int maxRemainder = max % i;
            System.out.println(String.format("4(%s), 余数：min %s, max %s", i, minRemainder, maxRemainder));
            System.out.println();
            countLT25(minRemainder, maxRemainder);
        } else {
            countLT25(min, max);
        }

//        Integer clm = (clm - 1) * 2;

//        Integer minCounter = 0;
//        Integer maxCounter = 0;
//        boolean base = base(min, max);
//        if (base) return;
//        if (min % 2 != 0 || max % 2 != 0) {
//            min = min - 1;
//            minCounter += 1;
//            max = max - 1;
//            maxCounter += 1;
//        }
//        System.out.println(String.format("%s:%s:%s:%s\n", min, max, minCounter, maxCounter));
//        int minLcm = min / 2;
//        int maxLcm = max / 2;
//        System.out.println(String.format("2的%s次方, sum:%s", (minLcm + maxLcm), (minLcm + maxLcm) * 2));
//        System.out.println();
    }

//    private Integer aa(Integer max) {
//        int i = max % 3;
//        if (i == 0) {
//
//        }
//    }
    private void countLT25(Integer min, Integer max) {
        boolean judge = max > min;
        Integer clm = judge ? (max / min) : (min / max);
        System.out.println(String.format("%s(%s), 余数：%s %s", clm, min, judge ? "max" : "min", max % min));
    }
    private Integer baseSum(Integer min, Integer max, boolean isEven) {
//        if (base(min, max)) {
//            return 0;
//        }
        if (min % 2 != 0 || max % 2 != 0) {
            isEven = true;
            min = min - 1;
            max = max - 1;
        }
//        if (base(min, max)) {
//            return 0;
//        }
        int minLcm = min / 2;
        int maxLcm = max / 2;
        return minLcm;
    }
    private void aa(Integer min, Integer max, Integer countSize, Integer size) {
        System.out.println(String.format("%s-%s-%s-%s", min, max, countSize, size));
        if (max % min == 0) {
            return;
        }
        if (min % 2 != 0 || max % 2 != 0) {
            min = min - 1;
            max = max - 1;
            countSize += 1;
        }
        if (max % min == 0) {
            return;
        }
        min = min / 2;
        max = max / 2;
        size += 1;
        aa(min, max, countSize, size);
    }
    private boolean base(Integer min, Integer max) {
        if (0 != max % min) {
            return false;
        }
        // 最小倍数
        int lcm = max / min;
        // 倍数次数
        int lcmFrequency = max / lcm + min / lcm;
        String lcmNumber = generateLcmNumber(lcm - 1);
        String s = generateLcmFrequencyNumber(lcmNumber, lcmFrequency);

        System.out.println(String.format("%s(%s)", lcm, lcmFrequency));
        return true;
    }
    private String generateLcmNumber(int size) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < size; i++) {
            sb.append(1);
        }
        sb.append(0);
        return sb.toString();
    }
    private String generateLcmFrequencyNumber(String lcmNumber, Integer lcmFrequency) {
        StringBuilder sb = new StringBuilder();
        for (Integer i = 0; i < lcmFrequency; i++) {
            sb.append(lcmNumber);
        }
        return sb.toString();
    }

}
